package com.yc.d0415;

public class 线程方法 {
    public static void main(String[] args) {

        Thread t1 = new Thread(()->{
            for (int i = 0; i < 20 ; i++) {
                System.out.println("扫地" + i);
                try {
                    Thread.sleep(50);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        Thread t2 = new Thread(()->{
            for (int i = 0; i < 20 ; i++) {
                System.out.println("擦窗" + i);
                try {
                    if (i == 10) {
                        //加入t1之后,在t1执行完之后在执行
                        t1.join();
                    }
                    Thread.sleep(80);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        t1.start();
        t2.start();
    }
}
